package cn.com.surker.lab.vo;

import cn.com.surker.lab.entity.LabExpend;
import cn.com.surker.util.MathUtils;
import cn.com.surker.util.StringUtils;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @Author lucky
 * @create 2024年12月30 14:56
 * @desc 料仓消耗统计
 */
@Data
public class LabExpendVo extends LabExpend implements Serializable {

    private static final long serialVersionUID = 1L;

    /**生产线名称**/
    private String lineName;
    /**仓位名称**/
    private String storageName;
    /**仓位名称**/
    private String nameNorms;

    private Date batchTime;
    /**
     * 盘方量
     */
    private Double batchStere;
    /**
     * 材料品种
     */
    private Integer materialBreedType;
    /**
     * 盘号
     */
    private Integer batchNum;
    /**
     * 材料类型
     */
    private Integer materialType;
	/**
	 * 配合用量(汇总)
	 **/
    private Double labQuantity;
	/**工控设定用量(汇总)**/
    private Double setQuantity;
	/**实际下料用量(汇总)**/
    private Double realQuantity;
    /**误差值**/
    private Double errorValue;
    /**误差率**/
    private Double errorRate;

	/**
	 * 误差值(单盘)
	 **/
	private Double conErrorValue;
	/**
	 * 误差率(单盘)
	 **/
	private Double conErrorRate;

    private Integer type;

    private Double labDosage;
    private Double setDosage;
    private Double realDosage;
    private Double errorDosage;
    private Double proStere;
    /**强度**/
    private String strength;

    public Double getLabQuantity() {
        if (StringUtils.isNull(labQuantity))
            return 0.0;
        return StringUtils.formatDouble(labQuantity / 1000, 2);
    }
    public Double getSetQuantity() {
        if (StringUtils.isNull(setQuantity))
            return 0.0;
        return StringUtils.formatDouble(setQuantity / 1000, 2);
    }
    public Double getRealQuantity() {
        if (StringUtils.isNull(realQuantity))
            return 0.0;
        return StringUtils.formatDouble(realQuantity / 1000, 2);
    }

	public Double getErrorValue() {
		if (StringUtils.isNull(errorValue))
			return 0.0;
		return StringUtils.formatDouble(errorValue / 1000, 2);
	}

	public Double getConErrorValue() {
        if (StringUtils.isNull(getControlRealQuantity()))
            return 0.0;
        if (StringUtils.isNull(getControlSetQuantity()))
            return 0.0;
		conErrorValue = MathUtils.subtract(getControlRealQuantity(), getControlSetQuantity());
		return conErrorValue;
	}

	public Double getConErrorRate() {
        if (StringUtils.isNull(conErrorValue))
            return 0.0;
        if (StringUtils.isNull(getControlSetQuantity()))
            return 0.0;
		conErrorRate = MathUtils.divide(conErrorValue, getControlSetQuantity(), 6);
		conErrorRate = MathUtils.multiply(conErrorRate,100d);
		return conErrorRate;
	}
}
